package com.qkjia.path;

import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * 路径演示 1
 */
public class PathDemo1 {

    public static void main(String[] args) {
        // 创建path实例
        Path path = Paths.get("e:\\qkjia\\01.txt");

        // 创建相对路径
        // 代码1
        Path projects = Paths.get("e:\\qkjia", "projects");

        // 代码2
        // 将路径字符串或连接形成路径字符串的字符串序列转换为Path
        Path file = Paths.get("e:\\qkjia", "projects\\002.txt");


        String originalPath = "e:\\qkjia\\projects\\..\\yygh-project";

        Path path1 = Paths.get(originalPath);
        System.out.println("path1 = " + path1);

        //  path1.normalize(); 返回一个路径，该路径是消除了冗余名称元素的路径。
        Path path2 = path1.normalize();
        System.out.println("path2 = " + path2);

    }
}
